package org.lxw.stock;

import java.nio.ByteBuffer;
import java.util.AbstractList;

public class StockDayList extends AbstractList<DayFileBlock> {
	final ByteBuffer buffer;

	public StockDayList(byte[] bs) {
		if (bs == null)
			throw new IllegalArgumentException();
		buffer = ByteBuffer.wrap(bs);
	}

	@Override
	public DayFileBlock get(int index) {
		buffer.position(index * 32);
		buffer.limit(32);
		return new DayFileBlock(buffer.slice());
	}

	@Override
	public int size() {
		return buffer.capacity() / 32;
	}

}